<template>
	<view>
		<view class="d-waikuang-10">
			<uni-forms
				:modelValue="formData" 
				label-position="top"
			>
				<view class="d-kuan d-shang-10">
					<view class="d-beijing-hui">
						<uni-easyinput 
							@input="descInput($event)"
							type="textarea" 
							autoHeight 
							v-model="neirong" 
							placeholder="( *必须 ) 请输入您的答案" 
							placeholder-style="color:#b8b8b8;font-size:32rpx;text-align:center;"
							placeholder-class="place-holder"
							:inputBorder="false"
							:border="true"
							maxlength="-1"
						>
						</uni-easyinput>
					</view>
				</view>
				<view class="d-kuan d-shang-10">
					<view class="example-body">
						<u-upload
							:fileList="fileList1"
							@afterRead="afterRead"
							@delete="deletePic"
							name="1"
							multiple
							:maxCount="9"
						></u-upload>
					</view>
				</view>
			</uni-forms>
			
		</view>
		
		<view class="goods-carts">
			<view class="d-waikuang-10">
				<view class="d-kuan d-beijing-bai d-yuanjiao-10 ">
					<view class="d-neikuang-zuoyou-6-shangxia-10">
			    		<u-button text="提 交" form-type="submit" @click="postTiezidaan" shape="circle" color="linear-gradient(to right, rgb(67, 185, 185), rgb(168, 46, 208))"></u-button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import config from "../../utils/config";
var Api = require("../../utils/api.js");
var util = require("../../utils/util.js");

var pageCount = config.getPageCount;
var wxApi = require("../../utils/wxApi.js");
var wxRequest = require("../../utils/wxRequest.js");
var webSiteName = config.getWebsiteName;
var domain = config.getDomain;
var banbenhao = config.getDuixinbanbenhao;

export default {
	data() {
		return {
			formData:{},
			neirong:'',
			fileList1:[],
			tieids:'',
			cids:'',
			uid:'',
			keycode:'',
			member:[]
			
		};
	},
	onLoad: function (options) {
		var duixin = this;
		duixin.tieids = options.tid;
		duixin.cids = options.cid;
		var keycode = uni.getStorageSync('keycode');
		var member = uni.getStorageSync('member');
		var uid = uni.getStorageSync('memberuid');
		duixin.keycode = keycode;
		duixin.member = member;
		duixin.uid = uid;
	},
	methods: {
		//提交答案
		postTiezidaan(){
			var duixin = this;
			//console.log('duixin.neirong',duixin.neirong);
			var datas = "is_ajax=1&data[daan]="+duixin.neirong;
		    var postWendadaanRequest = wxRequest.postRequest(Api.postWendadaan(duixin.uid,duixin.keycode,duixin.cids,duixin.tieids),datas);
			postWendadaanRequest.then(response => {
				if (response.data.code == 1) {
					uni.showToast({
						title: response.data.msg,
						icon: 'success',
						duration: 5000
					});
					
					//返回上一级
					duixin.fanhui();
				}
			});
		},
		descInput(e){
			var duixin = this; 
		   let newStr = '<p>' + e + '</p>';
		   let content = newStr.replace(/\n/g,"</p><p>");
		   duixin.neirong = content;
		   console.log(duixin.neirong)
		},
		fanhui() {
			const pages = getCurrentPages();  //判断跳转了多少页
			if (pages.length === 2) {  
				uni.navigateBack({
					delta: 1
				});
			} else if (pages.length === 1) { //如果没有上一页返回首页
				uni.switchTab({
					url: '/pages/index/index',
				})
			} else {
				uni.navigateBack({
					delta: 1
				});
			}
			
		},
	}
}
</script>

<style>
	
	/* #ifdef H5 */
	::v-deep .uni-textarea-textarea {
	    resize: none;
	    background: none;
	    color: inherit;
	    opacity: 1;
	    font: inherit;
	    /* line-height: inherit; */
	    letter-spacing: inherit;
	    text-align: inherit;
	    text-indent: inherit;
	    text-transform: inherit;
	    text-shadow: inherit;
	    font-size: 18px;
	    line-height: 30px;
	}
	/* #endif */
	.uni-textarea-textarea {
	    resize: none;
	    background: none;
	    color: inherit;
	    opacity: 1;
	    font: inherit;
	    /* line-height: inherit; */
	    letter-spacing: inherit;
	    text-align: inherit;
	    text-indent: inherit;
	    text-transform: inherit;
	    text-shadow: inherit;
	    font-size: 18px;
	    line-height: 30px;
	}
	.place-holder {
		color:#b8b8b8;font-size:32rpx;text-align:center;
	}
</style>